package com.spring.demo.publicutil.methodstring;

/**
 * java 数字转换 123 转 一百二十三
 * @author youjc
 * @date 2022年05月22日 12:18
 */
public class NumericConversion {

    public static String intToChineseNum(int src){
        final String num[] = {"零","一","二","三","四","五","六","七","八","九"};
        final String unit[]={"","十","百","千","万","十","百","千","亿","十","百","千"};
        String dst ="";
        int count=0;
        while (src>0){
            dst=(num[src%10]+unit[count])+dst;
            src = src/10;
            count++;
        }
        return dst.replaceAll("零[千百十]","零").replaceAll("零+万","万")
                .replaceAll("零+亿","亿").replaceAll("亿万","亿零")
                .replaceAll("零+","零").replaceAll("零$","");
    }

}
